<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>事件</title>
	<style type="text/css">
		#box{
			width: 100px;
			height: 100px;
			background-color: blue;
		}
	</style>
</head>
<body>
	 <!-- <div id="box" onclick="add();"></div> -->
	 <div id="box" ></div>

	 <script type="text/javascript">
	 	var oDiv = document.getElementById('box');

	 	var isBlue = true;
	 	oDiv.onclick = function(){
	 		if (isBlue) {
	 			// this 指向了当前的元素节点对象
	 			this.style.backgroundColor = 'red';
	 			isBlue = false;
	 		}else{
				this.style.backgroundColor = 'blue';
	 			isBlue = true;
	 		}
	 	};
	 	// function add(){
	 	// 	alert(1111);
	 	// }
	 	
	 </script>

</body>
</html>